wait_timeout = "10"
send_loop_times = 10

mqtt_cmd = [
    {
        "cmd": 'AT+FSDEL="cacert.pem"',
        "match": '.*',
        "wait": b'OK',
        "timeout": wait_timeout
    },
    {
        "cmd": 'AT+FSDEL="client-cert.pem"',
        "match": '.*',
        "wait": b'OK',
        "timeout": wait_timeout
    },
    {
        "cmd": 'AT+FSDEL="client-key.pem"',
        "match": '.*',
        "wait": b'OK',
        "timeout": wait_timeout
    },
    # 普通MQTT流程
    {
        "cmd": 'AT+MCONFIG="airtest","user","password"',
        "match": 'AT\+MCONFIG="airtest","user","password"\s{4}OK\s{2}',
    },
    {
        "cmd": 'AT+MIPSTART="airtest.openluat.com",1883',
        "match": 'AT\+MIPSTART="airtest.openluat.com",1883\s{4}OK\s{4}CONNECT OK\s{2}',
        "wait": b'CONNECT OK',
        "timeout": wait_timeout
    },
    {
        "cmd": 'AT+MCONNECT=1,60',
        "match": 'AT\+MCONNECT=1,60\s{4}OK\s{4}CONNACK OK\s{2}',
        "wait": b'CONNACK OK',
        "timeout": wait_timeout
    },
    {
        "cmd": 'AT+MSUB="/hello/test",0',
        "match": 'AT\+MSUB="/hello/test",0\s{4}OK\s{4}SUBACK\s{2}',
        "wait": b'SUBACK',
        "timeout": wait_timeout
    },
    {
        "cmd": 'AT+MQTTMSGSET=0',
        "match": 'AT\+MQTTMSGSET=0\s{4}OK\s{2}'
    },
    {
        "cmd": 'AT+MPUB="/hello/test",0,0,"***PPPPP1234A___+++"',
        "match": 'AT\+MPUB="/hello/test",0,0,"\*\*\*PPPPP1234A___\+\+\+"\s{4}OK\s{4}\+MSUB: "/hello/test",19 byte,\*\*\*PPPPP1234A___\+\+\+\s{2}',
        "loop": send_loop_times,
        "wait": b'+MSUB: "/hello/test",19 byte,***PPPPP1234A___+++',
        "timeout": wait_timeout
    },
    # {
    #     "cmd": 'AT+MPUBEX="/hello/test",0,0,19\r\n***PPPPP1234A___+++',
    #     "match": 'AT\+MPUBEX="/hello/test",0,0,19\s{2}>\*\*\*PPPPP1234A___\+\+\+\s{2}OK\s{4}\+MSUB: "/hello/test",19 byte,\*\*\*PPPPP1234A___\+\+\+\s{2}',
    #     "enter": False,
    #     "loop": send_loop_times,
    #     "wait": b'+MSUB: "/hello/test",19 byte,***PPPPP1234A___+++',
    #     "timeout": wait_timeout
    # },
    {
        "cmd": 'AT+MQTTMSGSET=1',
        "match": 'AT\+MQTTMSGSET=1\s{4}OK\s{2}'
    },
    # {
    #     "cmd": 'AT+MPUB="/hello/test",0,0,"***PPPPP1234A___+++"',
    #     "match": 'AT\+MPUB="/hello/test",0,0,"\*\*\*PPPPP1234A___\+\+\+"\s{4}OK\s{4}\+MSUB: \d\s{2}',
    #     "loop": 4,
    #     "wait": b'+MSUB: ',
    #     "timeout": wait_timeout
    # },
    # {
    #     "cmd": 'AT+MQTTMSGGET',
    #     "match": 'AT\+MQTTMSGGET\s{4}\+MSUB: "/hello/test",19 byte,\*\*\*PPPPP1234A___\+\+\+\s{2}\+MSUB: "/hello/test",19 byte,\*\*\*PPPPP1234A___\+\+\+\s{2}\+MSUB: "/hello/test",19 byte,\*\*\*PPPPP1234A___\+\+\+\s{2}\+MSUB: "/hello/test",19 byte,\*\*\*PPPPP1234A___\+\+\+\s{4}OK\s{2}',
    #     "wait": b'OK',
    #     "timeout": wait_timeout
    # },
    # {
    #     "cmd": 'AT+MPUBEX="/hello/test",0,0,19\r\n***PPPPP1234A___+++',
    #     "match": 'AT\+MPUBEX="/hello/test",0,0,19\s{2}>\*\*\*PPPPP1234A___\+\+\+\s{2}OK\s{4}\+MSUB: \d\s{2}',
    #     "enter": False,
    #     "loop": 4,
    #     "wait": b'+MSUB: ',
    #     "timeout": wait_timeout
    # },
    # {
    #     "cmd": 'AT+MQTTMSGGET',
    #     "match": 'AT\+MQTTMSGGET\s{4}\+MSUB: "\/hello\/test",19 byte,\*\*\*PPPPP1234A___\+\+\+\s{2}\+MSUB: "\/hello\/test",19 byte,\*\*\*PPPPP1234A___\+\+\+\s{2}\+MSUB: "\/hello\/test",19 byte,\*\*\*PPPPP1234A___\+\+\+\s{2}\+MSUB: "\/hello\/test",19 byte,\*\*\*PPPPP1234A___\+\+\+\s{4}OK\s{2}',
    #     "wait": b'OK',
    #     "timeout": wait_timeout
    # },
    {
        "cmd": 'AT+MDISCONNECT',
        "match": 'AT\+MDISCONNECT\s{4}OK\s{2}',
    },
    {
        "cmd": 'AT+MIPCLOSE',
        "match": 'AT\+MIPCLOSE\s{4}OK\s{2}',
    },
    # 带证书的MQTTSSL连接(单向认证)
    {
        "cmd": 'AT+FSCREATE=cacert.pem',
        "match": 'AT\+FSCREATE=cacert\.pem\s{4}OK\s{2}',
        "wait": b'OK',
        "timeout": wait_timeout
    },
    {
        "cmd": 'AT+FSWRITE=cacert.pem,0,1212,20',
        "match": 'AT\+FSWRITE=cacert\.pem,0,1212,20\s{4}>',
        "wait": b">",
        "timeout": wait_timeout
    },
    {
        "cmd": open("certs/mqtt/cacert.pem", "rb").read().decode(encoding="utf-8"),
        "match": '\s{2}OK\s{2}',
        "enter": False,
        "wait": b'OK',
        "timeout": wait_timeout
    },
    {
        "cmd": "AT+FSREAD=cacert.pem,0,1212,0",
        "match": '.*',
        "wait": b'OK',
        "timeout": wait_timeout
    },
    {
        "cmd": 'AT+SSLCFG="cacert",88,"cacert.pem"',
        "match": 'AT\+SSLCFG="cacert",88,"cacert\.pem"\s{4}OK\s{2}',
    },
    {
        "cmd": 'AT+SSLCFG="seclevel",88,1',
        "match": 'AT\+SSLCFG="seclevel",88,1\s{4}OK\s{2}',
    },
    {
        "cmd": 'AT+SSLMIPSTART="airtest.openluat.com",8883',
        "match": 'AT\+SSLMIPSTART="airtest.openluat.com",8883\s{4}OK\s{4}CONNECT OK\s{2}',
        "wait": b'CONNECT OK',
        "timeout": wait_timeout
    },
    {
        "cmd": 'AT+MCONNECT=1,60',
        "match": 'AT\+MCONNECT=1,60\s{4}OK\s{4}CONNACK OK\s{2}',
        "wait": b'CONNACK OK',
        "timeout": wait_timeout
    },
    {
        "cmd": 'AT+MQTTMSGSET=0',
        "match": 'AT\+MQTTMSGSET=0\s{4}OK\s{2}'
    },
    {
        "cmd": 'AT+MSUB=MQTT-TEST1,2',
        "match": 'AT\+MSUB=MQTT-TEST1,2\s{4}OK\s{4}SUBACK\s{2}',
        "wait": b'SUBACK',
        "timeout": wait_timeout
    },
    {
        "cmd": 'AT+MPUB=MQTT-TEST1,2,0,"hello,server!!!!--SSL with  certificate"',
        "match": 'AT\+MPUB=MQTT-TEST1,2,0,"hello,server!!!!--SSL with  certificate"\s{4}OK\s{4}PUBREC\s{4}\+MSUB: "MQTT-TEST1",39 byte,hello,server!!!!--SSL with  certificate\s{4}PUBCOMP\s{2}',
        "loop": send_loop_times,
        "wait": b'PUBCOMP',
        "timeout": wait_timeout
    },
    {
        "cmd": 'AT+MDISCONNECT',
        "match": 'AT\+MDISCONNECT\s{4}OK\s{2}',
    },
    {
        "cmd": 'AT+MIPCLOSE',
        "match": 'AT\+MIPCLOSE\s{4}OK\s{2}',
    },
    # 带证书的MQTTSSL连接(双向认证)
    {
        "cmd": 'AT+FSCREATE=client-cert.pem',
        "match": 'AT\+FSCREATE=client-cert\.pem\s{4}OK\s{2}',
        "wait": b'OK',
        "timeout": wait_timeout
    },
    {
        "cmd": 'AT+FSWRITE=client-cert.pem,0,1127,20',
        "match": 'AT\+FSWRITE=client-cert\.pem,0,1127,20\s{4}>',
        "wait": b">",
        "timeout": wait_timeout
    },
    {
        "cmd": open("certs/mqtt/client-cert.pem", "rb").read().decode(encoding="utf-8"),
        "match": '\s{2}OK\s{2}',
        "enter": False,
        "wait": b'OK',
        "timeout": wait_timeout
    },
    {
        "cmd": "AT+FSREAD=client-cert.pem,0,1127,0",
        "match": '.*',
        "wait": b'OK',
        "timeout": wait_timeout
    },
    {
        "cmd": 'AT+FSCREATE=client-key.pem',
        "match": 'AT\+FSCREATE=client-key\.pem\s{4}OK\s{2}',
        "wait": b'OK',
        "timeout": wait_timeout
    },
    {
        "cmd": 'AT+FSWRITE=client-key.pem,0,1679,20',
        "match": 'AT\+FSWRITE=client-key\.pem,0,1679,20\s{4}>',
        "wait": b">",
        "timeout": wait_timeout
    },
    {
        "cmd": open("certs/mqtt/client-key.pem", "rb").read().decode(encoding="utf-8"),
        "match": '\s{2}OK\s{2}',
        "enter": False,
        "wait": b'OK',
        "timeout": wait_timeout
    },
    {
        "cmd": "AT+FSREAD=client-key.pem,0,1679,0",
        "match": '.*',
        "wait": b'OK',
        "timeout": wait_timeout
    },
    {
        "cmd": 'AT+SSLCFG="clientcert",88,"client-cert.pem"',
        "match": 'AT\+SSLCFG="clientcert",88,"client-cert\.pem"\s{4}OK\s{2}',
    },
    {
        "cmd": 'AT+SSLCFG="clientkey",88,"client-key.pem"',
        "match": 'AT\+SSLCFG="clientkey",88,"client-key\.pem"\s{4}OK\s{2}',
    },
    {
        "cmd": 'AT+SSLCFG="seclevel",88,2',
        "match": 'AT\+SSLCFG="seclevel",88,2\s{4}OK\s{2}',
    },
    {
        "cmd": 'AT+SSLMIPSTART="airtest.openluat.com",8883',
        "match": 'AT\+SSLMIPSTART="airtest.openluat.com",8883\s{4}OK\s{4}CONNECT OK\s{2}',
        "wait": b'CONNECT OK',
        "timeout": wait_timeout
    },
    {
        "cmd": 'AT+MCONNECT=1,60',
        "match": 'AT\+MCONNECT=1,60\s{4}OK\s{4}CONNACK OK\s{2}',
        "wait": b'CONNACK OK',
        "timeout": wait_timeout
    },
    {
        "cmd": 'AT+MQTTMSGSET=0',
        "match": 'AT\+MQTTMSGSET=0\s{4}OK\s{2}'
    },
    {
        "cmd": 'AT+MSUB=MQTT-TEST1,2',
        "match": 'AT\+MSUB=MQTT-TEST1,2\s{4}OK\s{4}SUBACK\s{2}',
        "wait": b'SUBACK',
        "timeout": wait_timeout
    },
    {
        "cmd": 'AT+MPUB=MQTT-TEST1,2,0,"hello,server!!!!--SSL with  certificate"',
        "match": 'AT\+MPUB=MQTT-TEST1,2,0,"hello,server!!!!--SSL with  certificate"\s{4}OK\s{4}PUBREC\s{4}\+MSUB: "MQTT-TEST1",39 byte,hello,server!!!!--SSL with  certificate\s{4}PUBCOMP\s{2}',
        "loop": send_loop_times,
        "wait": b'PUBCOMP',
        "timeout": wait_timeout
    },
    {
        "cmd": 'AT+MDISCONNECT',
        "match": 'AT\+MDISCONNECT\s{4}OK\s{2}',
    },
    {
        "cmd": 'AT+MIPCLOSE',
        "match": 'AT\+MIPCLOSE\s{4}OK\s{2}',
    },
    # 不带证书的MQTTSSL连接
    {
        "cmd": 'AT+SSLMIPSTART="airtest.openluat.com",8883',
        "match": 'AT\+SSLMIPSTART="airtest.openluat.com",8883\s{4}OK\s{4}CONNECT OK\s{2}',
        "wait": b'CONNECT OK',
        "timeout": wait_timeout
    },
    {
        "cmd": 'AT+MCONNECT=1,60',
        "match": 'AT\+MCONNECT=1,60\s{4}OK\s{4}CONNACK OK\s{2}',
        "wait": b'CONNACK OK',
        "timeout": wait_timeout
    },
    {
        "cmd": 'AT+MQTTMSGSET=0',
        "match": 'AT\+MQTTMSGSET=0\s{4}OK\s{2}'
    },
    {
        "cmd": 'AT+MSUB=MQTT-TEST1,2',
        "match": 'AT\+MSUB=MQTT-TEST1,2\s{4}OK\s{4}SUBACK\s{2}',
        "wait": b'SUBACK',
        "timeout": wait_timeout
    },
    {
        "cmd": 'AT+MPUB=MQTT-TEST1,2,0,"hello,server!!!!--SSL with  certificate"',
        "match": 'AT\+MPUB=MQTT-TEST1,2,0,"hello,server!!!!--SSL with  certificate"\s{4}OK\s{4}PUBREC\s{4}\+MSUB: "MQTT-TEST1",39 byte,hello,server!!!!--SSL with  certificate\s{4}PUBCOMP\s{2}',
        "loop": send_loop_times,
        "wait": b'PUBCOMP',
        "timeout": wait_timeout
    },
    {
        "cmd": 'AT+MDISCONNECT',
        "match": 'AT\+MDISCONNECT\s{4}OK\s{2}',
    },
    {
        "cmd": 'AT+MIPCLOSE',
        "match": 'AT\+MIPCLOSE\s{4}OK\s{2}',
    },
    # MQTT命令测试
    {
        "cmd": 'AT+MIPSTART="airtest.openluat.com",1883',
        "match": 'AT\+MIPSTART="airtest.openluat.com",1883\s{4}OK\s{4}CONNECT OK\s{2}',
        "wait": b'CONNECT OK',
        "timeout": wait_timeout
    },
    {
        "cmd": 'AT+MQTTSTATU',
        "match": 'AT\+MQTTSTATU\s{4}\+MQTTSTATU :2\s{4}OK\s{2}',
        "wait": b'OK',
        "timeout": wait_timeout
    },
    {
        "cmd": 'AT+MCONNECT=1,60',
        "match": 'AT\+MCONNECT=1,60\s{4}OK\s{4}CONNACK OK\s{2}',
        "wait": b'CONNACK OK',
        "timeout": wait_timeout
    },
    {
        "cmd": 'AT+MQTTMSGSET=0',
        "match": 'AT\+MQTTMSGSET=0\s{4}OK\s{2}'
    },
    {
        "cmd": 'AT+MSUB="/hello/test",0',
        "match": 'AT\+MSUB="/hello/test",0\s{4}OK\s{4}SUBACK\s{2}',
        "wait": b'SUBACK',
        "timeout": wait_timeout
    },
    {
        "cmd": 'AT+MPUB="/hello/test",0,0,"***PPPPP1234A___+++"',
        "match": 'AT\+MPUB="/hello/test",0,0,"\*\*\*PPPPP1234A___\+\+\+"\s{4}OK\s{4}\+MSUB: "/hello/test",19 byte,\*\*\*PPPPP1234A___\+\+\+\s{2}',
        "loop": send_loop_times,
        "wait": b'+MSUB: "/hello/test",19 byte,***PPPPP1234A___+++',
        "timeout": wait_timeout
    },
    {
        "cmd": 'AT+MUNSUB="/hello/test"',
        "match": 'AT\+MUNSUB="/hello/test"\s{4}OK\s{4}UNSUBACK\s{2}',
        "wait": b'UNSUBACK',
        "timeout": wait_timeout
    },
    {
        "cmd": 'AT+MPUB="/hello/test",0,0,"***PPPPP1234A___+++"',
        "match": 'AT\+MPUB="/hello/test",0,0,"\*\*\*PPPPP1234A___\+\+\+"\s{4}OK\s{2}',
        "loop": send_loop_times,
        "wait": b'OK',
        "timeout": wait_timeout
    },

    {
        "cmd": 'AT+MQTTMSGGET?',
        "match": 'AT\+MQTTMSGGET\?\s{4}\+MQTTMSGGET: 0,INVALID\s{2}\+MQTTMSGGET: 1,INVALID\s{2}\+MQTTMSGGET: 2,INVALID\s{2}\+MQTTMSGGET: 3,INVALID\s{4}OK\s{2}',
        "wait": b'OK',
        "timeout": wait_timeout
    },
    {
        "cmd": 'AT+MQTTMODE=1',
        "match": 'AT\+MQTTMODE=1\s{4}OK\s{2}',
    },
    {
        "cmd": 'AT+MQTTMODE?',
        "match": 'AT\+MQTTMODE\?\s{4}\+MQTTMODE:1\s{4}OK\s{2}',
        "wait": b'OK',
        "timeout": wait_timeout
    },
    {
        "cmd": 'AT+MQTTMODE=0',
        "match": 'AT\+MQTTMODE=0\s{4}OK\s{2}',
    },
    {
        "cmd": 'AT+MQTTMODE?',
        "match": 'AT\+MQTTMODE\?\s{4}\+MQTTMODE:0\s{4}OK\s{2}',
        "wait": b'OK',
        "timeout": wait_timeout
    },
    {
        "cmd": 'AT+MQTTMODE=?',
        "match": 'AT\+MQTTMODE=\?\s{4}\+MQTTMODE: \(0,1\)\s{4}OK\s{2}',
        "wait": b'OK',
        "timeout": wait_timeout
    },
    {
        "cmd": 'AT+MQTTSTATU',
        "match": 'AT\+MQTTSTATU\s{4}\+MQTTSTATU :1\s{4}OK\s{2}',
        "wait": b'OK',
        "timeout": wait_timeout
    },
    {
        "cmd": 'AT+MDISCONNECT',
        "match": 'AT\+MDISCONNECT\s{4}OK\s{2}',
    },
    {
        "cmd": 'AT+MIPCLOSE',
        "match": 'AT\+MIPCLOSE\s{4}OK\s{2}',
    },
    {
        "cmd": 'AT+MQTTSTATU',
        "match": 'AT\+MQTTSTATU\s{4}\+MQTTSTATU :0\s{4}OK\s{2}',
        "wait": b'OK',
        "timeout": wait_timeout
    },
    {
        "cmd": 'AT+MQTTSTATU=?',
        "match": 'AT\+MQTTSTATU=\?\s{4}OK\s{2}',
    },
    # MQTT边界值和合法性
    {
        "cmd": 'AT+MIPSTART="airtest.openluat.com",1883',
        "match": 'AT\+MIPSTART="airtest.openluat.com",1883\s{4}OK\s{4}CONNECT OK\s{2}',
        "wait": b'CONNECT OK',
        "timeout": wait_timeout
    },
    {
        "cmd": 'AT+MCONNECT=1,60',
        "match": 'AT\+MCONNECT=1,60\s{4}OK\s{4}CONNACK OK\s{2}',
        "wait": b'CONNACK OK',
        "timeout": wait_timeout
    },
    {
        "cmd": 'AT+MSUB=w/test/HELLO/this/that.yunzhou.com/888/gw/test/HELLO/this/that.yunzhou.com/888/gw/test/HELLO/this/that.yunzhou.com/888/gw/test/HELLO/thisgw/test/HELLO/this/that.yunzhou.com/888/gw/test/HELLO/this/that.yunzhou.com/888/gw/test/HELLO/this/that.yunzhou.com/888,0',
        "match": 'AT\+MSUB=w\/test\/HELLO\/this\/that.yunzhou.com\/888\/gw\/test\/HELLO\/this\/that.yunzhou.com\/888\/gw\/test\/HELLO\/this\/that.yunzhou.com\/888\/gw\/test\/HELLO\/thisgw\/test\/HELLO\/this\/that.yunzhou.com\/888\/gw\/test\/HELLO\/this\/that.yunzhou.com\/888\/gw\/test\/HELLO\/this\/that.yunzhou.com\/888,0\s{4}OK\s{4}SUBACK\s{2}',
        "wait": b'SUBACK',
        "timeout": wait_timeout
    },
    {
        "cmd": 'AT+MSUB=gw/test/HELLO/this/that.yunzhou.com/888/gw/test/HELLO/this/that.yunzhou.com/888/gw/test/HELLO/this/that.yunzhou.com/888/gw/test/HELLO/thisgw/test/HELLO/this/that.yunzhou.com/888/gw/test/HELLO/this/that.yunzhou.com/888/gw/test/HELLO/this/that.yunzhou.com/888,0',
        "match": 'AT\+MSUB=gw\/test\/HELLO\/this\/that.yunzhou.com\/888\/gw\/test\/HELLO\/this\/that.yunzhou.com\/888\/gw\/test\/HELLO\/this\/that.yunzhou.com\/888\/gw\/test\/HELLO\/thisgw\/test\/HELLO\/this\/that.yunzhou.com\/888\/gw\/test\/HELLO\/this\/that.yunzhou.com\/888\/gw\/test\/HELLO\/this\/that.yunzhou.com\/888,0\s{4}\+CME ERROR: 765\s{4}',
        "wait": b'+CME ERROR: 765',
        "timeout": wait_timeout
    },
    {
        "cmd": 'AT+MSUB=/TESTAIR/MQTT_%1,0',
        "match": 'AT\+MSUB=\/TESTAIR\/MQTT_%1,0\s{4}OK\s{4}SUBACK\s{2}',
        "wait": b'SUBACK',
        "timeout": wait_timeout
    },
    {
        "cmd": 'AT+MSUB=test,0',
        "match": 'AT\+MSUB=test,0\s{4}OK\s{4}SUBACK\s{2}',
        "wait": b'SUBACK',
        "timeout": wait_timeout
    },
    {
        "cmd": 'AT+MSUB=test,1',
        "match": 'AT\+MSUB=test,1\s{4}OK\s{4}SUBACK\s{2}',
        "wait": b'SUBACK',
        "timeout": wait_timeout
    },
    {
        "cmd": 'AT+MSUB=test,2',
        "match": 'AT\+MSUB=test,2\s{4}OK\s{4}SUBACK\s{2}',
        "wait": b'SUBACK',
        "timeout": wait_timeout
    },
    {
        "cmd": 'AT+MSUB=test,8',
        "match": 'AT\+MSUB=test,8\s{4}\+CME ERROR: 765\s{4}',
        "wait": b'+CME ERROR: 765',
        "timeout": wait_timeout
    },
    # {
    #     "cmd": 'AT+MPUB=test,0,0,12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901235',
    #     "match": 'AT\+MPUB=test,0,0,\d{2384}\s{4}OK\s{4}\+MSUB: "test",2384 byte,\d{2384}\s{2}',
    #     "wait": b'+MSUB: "test",2384 byte,12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901235\r\n',
    #     "timeout": wait_timeout
    # },
    {
        "cmd": 'AT+MPUB=test,1,0,1234567890QWERTYUIO',
        "match": 'AT\+MPUB=test,1,0,1234567890QWERTYUIO\s{4}OK\s{4}PUBACK\s{4}\+MSUB: "test",19 byte,1234567890QWERTYUIO\s{2}',
        "wait": b'+MSUB: "test",19 byte,1234567890QWERTYUIO',
        "timeout": wait_timeout
    },
    {
        "cmd": 'AT+MPUB=test,2,0,1234567890QWERTYUIO',
        "match": 'AT\+MPUB=test,2,0,1234567890QWERTYUIO\s{4}OK\s{4}PUBREC\s{4}\+MSUB: "test",19 byte,1234567890QWERTYUIO\s{4}PUBCOMP\s{2}',
        "wait": b'PUBCOMP',
        "timeout": wait_timeout
    },
    {
        "cmd": 'AT+MPUB=test,7,0,1234567890QWERTYUIO',
        "match": 'AT\+MPUB=test,7,0,1234567890QWERTYUIO\s{4}\+CME ERROR: 765\s{4}',
        "wait": b'+CME ERROR: 765',
        "timeout": wait_timeout
    },
    # {
    #     "cmd": 'AT+MPUBEX=test,0,0,2384',
    #     "match": 'AT\+MPUBEX=test,0,0,2384\s{2}>',
    #     "wait": b'>',
    #     "timeout": wait_timeout
    # },
    # {
    #     "cmd": '12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901235',
    #     "match": '\d{2384}\s{2}OK\s{4}\+MSUB: "test",2384 byte,\d{2384}',
    #     "wait": b'+MSUB: "test",2384 byte,12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901235\r\n',
    #     "timeout": wait_timeout
    # },
    # {
    #     "cmd": 'AT+MPUBEX=test,1,0,19\r\n1234567890QWERTYUIO',
    #     "match": 'AT\+MPUBEX=test,1,0,19\s{2}>1234567890QWERTYUIO\s{2}OK\s{4}PUBACK\s{4}\+MSUB: "test",19 byte,1234567890QWERTYUIO\s{2}',
    #     "wait": b'+MSUB: "test",19 byte,1234567890QWERTYUIO',
    #     "timeout": wait_timeout
    # },
    # {
    #     "cmd": 'AT+MPUBEX=test,2,0,19\r\n1234567890QWERTYUIO',
    #     "match": 'AT\+MPUBEX=test,2,0,19\s{2}>1234567890QWERTYUIO\s{2}OK\s{4}PUBREC\s{4}\+MSUB: "test",19 byte,1234567890QWERTYUIO\s{4}PUBCOMP\s{2}',
    #     "wait": b'PUBCOMP',
    #     "timeout": wait_timeout
    # },
    # {
    #     "cmd": 'AT+MPUBEX=test,7,0,19\r\n1234567890QWERTYUIO',
    #     "match": 'AT\+MPUBEX=test,7,0,19\s{4}\+CME ERROR: 765\s{4}1234567890QWERTYUIO\s{2}',
    #     "wait": b'1234567890QWERTYUIO',
    #     "timeout": wait_timeout
    # },
    {
        "cmd": 'AT+MDISCONNECT',
        "match": 'AT\+MDISCONNECT\s{4}OK\s{2}',
    },
    {
        "cmd": 'AT+MIPCLOSE',
        "match": 'AT\+MIPCLOSE\s{4}OK\s{2}',
    },
    {
        "cmd": 'AT+SSLCFG="cacert",88,',
        "match": 'AT\+SSLCFG="cacert",88,\s{4}OK\s{2}',
    },
    {
        "cmd": 'AT+SSLCFG="seclevel",88,',
        "match": 'AT\+SSLCFG="seclevel",88,\s{4}OK\s{2}',
    },
    {
        "cmd": 'AT+SSLCFG="clientcert",88,',
        "match": 'AT\+SSLCFG="clientcert",88,\s{4}OK\s{2}',
    },
    {
        "cmd": 'AT+SSLCFG="clientkey",88,',
        "match": 'AT\+SSLCFG="clientkey",88,\s{4}OK\s{2}',
    }
]
